<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Conexao
 *
 * @author Rafael Ferreira
 */
abstract class Conexao {
    
    const USER = "root";
    const PASS = "";
    
    private static $instance = null;
    
    private static function conectar(){
        try {
            if(self::$instance == NULL):
                $dsn = "mysql:host=localhost;dbname=completta_os";
                self::$instance = new PDO($dsn, self::USER, self::PASS);
                self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            endif;
        } catch (PDOException $e) {
            echo "Erro: ".$e->getMessage();
        }
        return self::$instance;
    }
    
    protected static function getBD(){
        return self::conectar();
    }
    
}
